package xc.com.course.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import xc.com.common.Result;
import xc.com.course.domain.TeachplanMedia;
import xc.com.course.service.TeachplanMediaService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhuolizhong
 * @since 2021-06-03
 */
@RestController
@RequestMapping("/teachplan-media")
@CrossOrigin
public class TeachplanMediaController {
    @Autowired
    private TeachplanMediaService teachplanMediaService;
    @PostMapping("/addTeachPlanMedia/{courseId}/{teachplanId}/{mediaName}")
    public Result addTeachPlanMedia(@PathVariable("courseId") String courseId,@PathVariable("teachplanId")  String teachplanId,@PathVariable("mediaName") String mediaName, MultipartFile file){
        return teachplanMediaService.addTeachPlanMedia(courseId, teachplanId, mediaName, file);
    }

    @GetMapping("findId/{id}")
    public TeachplanMedia findId(@PathVariable("id")String id ){
        return teachplanMediaService.findByTeachplanId(id);
    }

    @PostMapping("/addMedia")
    public Result addMedia(@RequestBody TeachplanMedia teachplanMedia){
        return teachplanMediaService.addMedia(teachplanMedia);
    }
}

